package de.velvettear.bruteforce.kernel.threads;

import de.velvettear.bruteforce.kernel.Statics;
import de.velvettear.bruteforce.kernel.StatusReport;
import de.velvettear.bruteforce.kernel.WordList;
import de.velvettear.bruteforce.util.Log;
import de.velvettear.bruteforce.util.Timestamp;


public class ExportThread extends Thread {

	private static int SLEEP = Statics.DEFAULT_SLEEP_EXPORT;
	
	private static boolean threadRunning = false;
	
	public static String WORD = "";
	public static String DONE = "";
	public static String TOTAL = "";
	public static String PERCENTAGE = "";
	public static String AVERAGE = "";
	public static String REMAINING = "";
		
	public ExportThread() {
		
	}
	
	public ExportThread(int sleep) {
		SLEEP = sleep;
	}	
	
	@Override
	public void run() {
		threadRunning = true;
						
		try {
			while (threadRunning) {				
				StatusReport.insert(WordList.currentWord, WordList.wordsCreated.toString(), WordList.possibilities.toString(), WordList.average.toString(), WordList.remaining.toString(), Timestamp.getSimple());
				
				Thread.sleep(SLEEP);
			}
		} catch (Exception e) {
			Log.error(e);
		}
		
	}
	
	public static void kill() {
		threadRunning = false;
	}
	
	public static boolean isRunning() {
		return threadRunning;
	}
		
}
